﻿using AuthCenter.Api.Read.Application.Command.User;
using AuthCenter.Api.Read.Application.Output;
using AuthCenter.Domain;
using AuthCenter.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AuthCenter.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class UserController : ControllerBase
    {
        private readonly IMediator mediator;
        public UserController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取省份
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<ProvinceModel>>> GetProviceShow([FromQuery]GetProviceShowCommand request) 
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 获取市
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<CityModel>>> GetCity([FromQuery] GetCityCommand request) 
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取县
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<CountyModel>>> GetCounty([FromQuery] GetCountyCommand request) 
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<UserOutput>>> GetUserShow([FromQuery] GetUserShowCommand request) 
        {
            return mediator.Send(request);
        }

        /// <summary>
        /// 根据部门获取用户
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<UserOutput>>> GetUser([FromQuery] GetUserCommand request) 
        {
            return mediator.Send(request);
        }
    }
}
